feature: Conversion of HSOpticalFlow Program to HIP#453
Merged
Conversation
zichguan-amd
requested changes
May 28, 2026
zichguan-amd
left a comment
Collaborator
There was a problem hiding this comment.
Please update the root README to include Applications/optical_flow, and Applications/Makefile to include the example.
- Add #include <hip/hip_runtime.h> to derivativesKernel.hip and downscaleKernel.hip (reviewer request for self-contained headers) - Fix LoadImageAsFP32 docstring: loads RGB (3-channel), not 4-channel - Update copyright year to 2026 in CMakeLists.txt and Makefile - Add optical_flow to Applications/Makefile EXAMPLES list - Add optical_flow entry to root README.md - Remove accidental .venv/ entry from root .gitignore - Rewrite optical_flow README with accurate build/run instructions: correct CMake compiler flag (clang++ not hipcc), ROCM_PATH and LD_LIBRARY_PATH env vars, working-directory-independent run instructions Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
zichguan-amd
approved these changes
Jun 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Closes #447
Ports the NVIDIA HSOpticalFlow CUDA sample to HIP as a new
Applications/optical_flowexample. The Horn-Schunck variational optical flow algorithm demonstrates several non-trivial HIP features (texture objects withhipResourceTypePitch2D, cooperative groups, Gaussian pyramids) that have no existing example in the repository.Technical Details
Implements the Horn-Schunck optical flow algorithm on HIP:
Downscale(4-tap filter viatex2Dbilinear fetch)iterative solver refines the flow
flowGold.cpp) runs the same algorithm on the host; the GPU and CPU results are compared via L1 norm per pixel (threshold: 0.05)FlowGPU.floandFlowCPU.floin Middlebury.floformatKey porting changes from CUDA:
helper_functions.h,sdkLoadPPM4ubstb_image.h(already in-repo)findCudaDevice(argc, argv)hipGetDeviceProperties(&props, 0)cooperative_groups.hhip/hip_cooperative_groups.hStrideAlignment = 32StrideAlignment = 64— ROCm requirespitchInBytesto be a multiple of 256 bytes forhipResourceTypePitch2DAll four texture wrappers (
downscaleKernel,upscaleKernel,warpingKernel,derivativesKernel) usehipResourceTypePitch2DwithhipAddressModeMirrorandhipFilterModeLinear, exercising the texture object API as it is typically used in production imaging workloads.Test Plan
Built and run with
makeon a ROCm-capable AMD GPU:cd Applications/optical_flow make ./optical_flowInput: two consecutive frames from the Middlebury optical flow dataset (data/frame10.ppm, data/frame11.ppm).
Test Result
HSOpticalFlow Starting...
Added/Updated documentation?
Submission Checklist